package com.ruoyi.user.service;

import com.ruoyi.user.domain.UserChatRecord;
import com.ruoyi.user.domain.ChatSession;
import com.ruoyi.user.domain.MessageAttachment;

import java.util.List;
import java.util.Map;

/**
 * 聊天记录Service接口
 */
public interface IUserChatRecordService {
    /**
     * 查询聊天记录
     */
    UserChatRecord selectUserChatRecordById(Long chatId);

    /**
     * 查询聊天记录列表
     */
    List<UserChatRecord> selectUserChatRecordList(UserChatRecord userChatRecord);

    /**
     * 查询会话聊天记录
     */
    List<UserChatRecord> selectUserChatRecordsBySession(Long sessionId, Long customerId);

    /**
     * 查询用户会话列表
     */
    List<ChatSession> selectUserSessions(Long customerId);

    /**
     * 查询会话信息
     */
    ChatSession selectSessionInfo(Long sessionId, Long customerId);

    /**
     * 新增聊天记录
     */
    int insertUserChatRecord(UserChatRecord userChatRecord);

    /**
     * 修改聊天记录
     */
    int updateUserChatRecord(UserChatRecord userChatRecord);

    /**
     * 删除聊天记录
     */
    int deleteUserChatRecordById(Long chatId);

    /**
     * 批量删除聊天记录
     */
    int deleteUserChatRecordByIds(Long[] chatIds);

    /**
     * 发送消息
     */
    Map<String, Object> sendMessage(Long sessionId, Long customerId, String content,
                                    Integer messageType, MessageAttachment attachment,
                                    String relatedOrderId); // 改为 String 类型

    /**
     * 标记消息为已读
     */
    Map<String, Object> markMessagesAsRead(Long sessionId, Long customerId, 
                                         Boolean readAll, List<Long> chatIds);

    /**
     * 清空会话聊天记录
     */
    Map<String, Object> clearSessionMessages(Long sessionId, Long customerId);

    /**
     * 查询会话未读消息数
     */
    int selectUnreadCountBySession(Long sessionId, Long customerId);

    /**
     * 查询用户总未读消息数
     */
    int selectTotalUnreadCount(Long customerId);

    /**
     * 获取未读消息统计
     */
    Map<String, Object> getUnreadMessageStats(Long customerId);

    /**
     * 创建或获取会话
     */
    Long getOrCreateSession(Long customerId, Integer chatType, Long targetId);
}